import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get_it/get_it.dart';
import 'package:sml_policies/locator/sml_policies.dart';
import 'package:sml_policies/sml_policies.dart';
import 'package:sml_policies_example/new_sml_policies/NewSmlPolicies.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  GetIt locator = GetIt.instance;

  @override
  void initState() {
    locator.registerSingleton(
      SmlPoliciesConfig(
        logEvent: (String eventName) {
          debugPrint('eventName: $eventName');
        },
        onToast: (String toastStr) {
          debugPrint('toastStr: $toastStr');
        }
      )
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 667),
      builder: (context, child) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('Plugin example app'),
            ),
            body: NewSmlPolicies(),
          ),
        );
      }
    );
  }
}
